package rss.builder 
{
	import rss.IRssEntryBuilder;
	import rss.IRssEntryModel;
	import rss.models.RssEntryModel;
	import common.utilities.Convert;
	/**
	 * Constructs a feed entry model from an RSS <item /> node.
	 * 
	 * @author Luke Van In
	 */
	public class XmlRssEntryBuilder implements IRssEntryBuilder 
	{
		
		// private variables
		private var _xml:XML;
		
		
		
		/**
		 * Constructor
		 * 
		 * @param	xml
		 */
		public function XmlRssEntryBuilder(xml:XML) 
		{
			this._xml = xml;
		}
		
		
		
		
		/* INTERFACE rss.IRssEntryBuilder */
		
		/**
		 * 
		 * @return
		 */
		public function buildEntry():IRssEntryModel 
		{
			// re-format category if category is missing or blank
			var category:String = this._xml.category.toString();
			
			if (category == "")
				category = "[None]";
							
			
			// create and return rss entry
			var entry:IRssEntryModel = new RssEntryModel(
				this._xml.title.toString(),
				this._xml.link.toString(),
				this._xml.description.toString(),
				Convert.stringToDate(this._xml.pubDate.toString()),
				this._xml.guid.toString(),
				category);
			
			return entry;
		}
		
		
		
		/**
		 * 
		 */
		public function dispose():void
		{
			
		}
		
		
	}

}